package com.richard.cloud.service;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.richard.cloud.entity.Storage;
import com.richard.cloud.repo.StorageRepo;

@Service
public class StorageService {
	@Resource
	private StorageRepo repo;
	
	//减库存
	//@Transactional
	public void decreaseStock(Long prodId, Integer count) {
		Storage entity = repo.findByProdId(prodId);
		entity.setStock(entity.getStock() - count);
		repo.saveAndFlush(entity);
	}
}
